package main

import (
	"arabApi/app/api/controllers/cronTask"
	"arabApi/bootstrap"
	btconfig "arabApi/config"
	"arabApi/pkg/config"
	"arabApi/pkg/pkgCron"
	"fmt"
	"github.com/gin-gonic/gin"
)

func init() {
	btconfig.Initialize()
}

func main() {
	main_func()
}

func main_func() {

	var env string
	config.InitConfig(env)
	// 初始化 Gin 实例
	r := gin.New()
	bootstrap.SetupRoute(r)
	bootstrap.SetupLogger()

	bootstrap.SetupDB()
	bootstrap.SetupRedis()

	gin.SetMode(gin.ReleaseMode)
	// 开启定时任务
	cronTask.CronStart()
	defer pkgCron.Cron.Stop()

	err := r.Run(":" + config.Get("app.port"))
	if err != nil {
		fmt.Println(err.Error())
	}

}
